exercises

Exercises#

Note: you can use online editor to work on the following exercises. Repl.it for example.

Exercise 1#

Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen.

Sample Output:

"0 is even"
"1 is odd"
"2 is even"
----------
----------

Exercise 2#

Note: This exercise illustrates how to use nested loops. So if there is no time to solve it, then it should be homework and discussed later.

Write a JavaScript program to construct the following pattern, using a nested for loop.

Pattern:

*
* *
* * *
* * * *
* * * * *